/*
 * @# register.js 2011-12-16 上午11:20:18
 * 
 * Copyright (C) 2010 - 2011 广州羿安信息科技有限公司 Guangzhou ianswer information
 * technology co. ltd.
 * 
 * All rights reserved!
 */


$(function() {
	
	// The uploadStart event handler.  This function variable is assigned to upload_start_handler in the settings object
var myCustomUploadStartEventHandler = function (file) {
	var continue_with_upload;
	
	if (file.name === "the sky is blue") {
		continue_with_upload = true;
	} else {
		continue_with_upload = false;
	}
	
	return continue_with_upload;
};

// The uploadSuccess event handler.  This function variable is assigned to upload_success_handler in the settings object
var myCustomUploadSuccessEventHandler = function (file, server_data, receivedResponse) {
	alert("The file " + file.name + " has been delivered to the server. The server responded with " + server_data);
};
	
	var swfu = new SWFUpload({
			upload_url : window.ctx+"/images/upload",  //上传地址
			file_post_name : "file", //上传文件参数名
	        flash_url : "../js/swfupload/Flash/SWFUpload.swf",  //flash所在位置  
	        allowed_filesize : 5120,   // 5 MB  
	        allowed_filetypes : "*.jpg,*.png,*.gif",  
	        allowed_filetypes_description : "All files(*.jpg,*.png,*.gif)",  
	        button_placeholder_id : 'choose-file-btn',
	        button_image_url : "http://www.swfupload.org/button_sprite.png",
			button_width : 61,
			button_height : 22,
			button_text : "<b>Click</b> <span class='redText'>here</span>",
			button_text_style : ".redText { color: #FF0000; }",
			button_text_left_padding : 3,
			button_text_top_padding : 2,
			button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,
			button_disable : false
		});
		
	$('#file-upload').click(function(e){
		swfu.startUpload();
	});
});